const express = require('express');
const cors = require('cors');
const app = express();
const port = 3000;

app.use(cors({ credentials: true, origin: true })); // 启用CORS
app.use(express.json()); // 用于解析JSON格式的请求体

app.post('/login', (req, res) => {
    const { username, password } = req.body;
    if (username === 'zzu' && password === '123') {
        res.json({ message: 'Login successful' });
    } else {
        res.status(401).json({ message: 'Login failed' }); // 返回401状态码表示未授权
    }
});

app.listen(port, () => {
    console.log(`Server listening at http://localhost:${port}`);
});
